<template>
	<div id="admission">


		<el-form :model="insertFrm" ref="insertFrm">

			<el-row>
				<el-col :span="3">
					<el-button type="infor" @click="chufangData" style="margin-left: 50px; width: 80px;background-color: cornflowerblue;">
						<b style="color: white;">处方</b>
					</el-button>
				</el-col>
				<el-col :span="3">
					<el-button type="infor" @click="bingliData" style="margin-left: -108px; width: 80px;background-color: cornflowerblue;">
						<b style="color: white;">病历</b>
					</el-button>
				</el-col>
			</el-row>


			<!-- 第一行 -->
			<el-row>
				<el-col :span="6">
					<el-form-item label="患者姓名">
						<el-input v-model="insertFrm.name" placeholder="请输入患者姓名" style="width: 290px;"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="患者卡号">
						<el-input v-model="insertFrm.serialnumber" placeholder="请输入患者卡号" style="width: 290px;"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="患者年龄">
						<el-input v-model="insertFrm.age" placeholder="请输入患者年龄" style="width: 290px;"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="出生日期">
						<el-date-picker v-model="insertFrm.birth" value-format="yyyy-MM-dd" style="width: 290px;" placeholder="请输入出生日期">
						</el-date-picker>
					</el-form-item>
				</el-col>
			</el-row>

			<!-- 第二行 -->
			<el-row>
				<el-col :span="6">
					<el-form-item label="性别">
						<el-select v-model="insertFrm.sex" placeholder="请选择性别" style="width: 290px;">
							<el-option :id="0" :value="0">女</el-option>
							<el-option :id="1" :value="1">男</el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="手机号码">
						<el-input v-model="insertFrm.phone" placeholder="请输入手机号码" style="width: 290px;"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="证件号码">
						<el-input v-model="insertFrm.personid" placeholder="请输入证件号码" style="width: 290px;"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="患者来源">
						<el-select v-model="insertFrm.sourceId" placeholder="请选择患者来源" style="width: 290px;">
							<el-option v-for="sou in source" :label="sou.name" :value="sou.id"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
			</el-row>

			<!-- 第四行 -->
			<el-row>
				<el-col :span="6">
					<el-form-item label="地址">
						<el-cascader v-model="ssq" :options="ssqs" :props="ssqsprops" @change="handleChange" style="width: 290px;"></el-cascader>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="详细地址">
						<el-input v-model="insertFrm.address" placeholder="请输入详细地址" style="width: 580px;"></el-input>
					</el-form-item>
				</el-col>
			</el-row>

			<!-- 第五行 -->
			<el-row>
				<el-col :span="11">
					<el-form-item label="诊断">
						<el-select v-model="insertFrm.diagnosisId" placeholder="诊断内容" style="width: 550px;">
							<el-option v-for="dia in diagnosis" :label="dia.name" :value="dia.id"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="5">
					<el-form-item label="医嘱">
						<el-select v-model="insertFrm.adviceId" placeholder="医嘱内容" style="width: 500px;">
							<el-option v-for="adv in advice" :label="adv.name" :value="adv.id"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
			</el-row>

		</el-form>




	</div>
</template>

<script>
	export default {
		data() {
			return {
				diagnosis: [],
				advice: [],
				source: [],
				ssq: [],
				ssqs: [],
				ssqsprops: {
					value: 'id',
					label: 'name',
					children: 'list'
				},
				insertFrm: {}
			}
		},
		created() {
			this.diagnosisData();
			this.adviceData();
			this.areaData();
			this.sourceData();
			this.initData();
		},
		methods: {
			diagnosisData() {
				this.axios.get('http://localhost:9993/diagnosis/list').then(res => {
					this.diagnosis = res.data.obj;
				})
			},
			adviceData() {
				this.axios.get('http://localhost:9993/advice/list').then(res => {
					this.advice = res.data.obj;
				})
			},
			initData() {
				if (this.$route.query.admiss) {
					this.insertFrm = this.$route.query.admissionData;
					console.log(this.$route.query.admissionData);
				}

			},
			sourceData() {
				this.axios.get('http://localhost:9993/source/list').then(res => {
					this.source = res.data.obj;
				})
			},
			areaData() {
				this.axios.get('http://localhost:9993/area/findAll').then(res => {
					this.ssqs = res.data;
				})
			},
			handleChange(val) {
				this.ssq = val;
			},
			chufangData() {
				this.$router.push("/admission");
			},
			bingliData() {
				this.$router.push("/medicalrecord");
			}
		}
	}
</script>

<style>
</style>
